public class ThreadDemo4 {
    public static int count1 = 0;
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
            for(int i = 0; i < 50000; i++) {
                synchronized (locker) {
                    count1++;
                }
            }
        });
        Thread t2 = new Thread(() -> {
            for(int i = 0; i < 50000; i++) {
                synchronized (locker) {
                    count1++;
                }
            }
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("count1 = " + count1);

        Thread t3 = new Thread(() -> {
           synchronized (locker) {
               synchronized (locker) {
                   System.out.println("可重入锁");
               }
           }
        });
        t3.start();
    }
}
